package com.angel.bo.admin.controller;

import com.angel.bo.admin.service.UserService;
import com.angel.bo.auth.client.annotation.IgnoreUserToken;
import com.angel.bo.beans.admin.entity.User;
import com.angel.bo.beans.admin.vo.UserVo;
import com.angel.bo.common.controller.BaseController;
import com.angel.bo.common.msg.WebReturn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Haibo.Mei [Haibo.Mei@ge.com]
 * @Description:
 * @Date: 16:02 2018/1/30
 */
@RestController
@RequestMapping("/user")
@Api(value = "UserController",description = "用户管理",tags = "用户管理")
public class UserController extends BaseController<UserService, User> {

    @Autowired
    private UserService userService;


    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @Override
    @ApiOperation(value = "保存用户信息")
    public WebReturn<User> add(@RequestBody User user) {
        return userService.saveUser(user);
    }

    @RequestMapping(value = "/getUserInfoByLoginName", method = RequestMethod.POST)
    @ApiOperation(value = "根据登录名获取用户信息")
    @IgnoreUserToken
    public WebReturn<User> getUserInfoByLoginName(@RequestBody String loginName) {
        return userService.getUserInfoByLoginName(loginName);
    }

    @Override
    public WebReturn<User> update(@RequestBody User user) {
        userService.updateSelectiveById(user);
        WebReturn webReturn = new WebReturn();
        return webReturn;
    }


    @RequestMapping(value = "/getUserPage", method = RequestMethod.POST)
    @ApiOperation(value = "获取用户PAGE")
    public WebReturn getUserPage(@RequestBody UserVo userVo){
        return userService.getUserPage(userVo);
    }
}
